package com.mycompany;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class Main {
    public static void main(String[] args) {
        // 初始化Spring容器
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
        OrderService orderService = context.getBean(OrderService.class);

        System.out.println("=== 测试add方法 ===");
        try {
            orderService.add("笔记本电脑", 1);
        } catch (Exception e) {
            System.out.println("错误信息: " + e.getMessage());
        }

        System.out.println("\n=== 测试delete方法 ===");
        try {
            orderService.delete("手机");
        } catch (Exception e) {
            System.out.println("错误信息: " + e.getMessage());
        }

        System.out.println("\n=== 测试find方法 ===");
        orderService.find("平板电脑");

        // 关闭容器
        context.close();
    }
}
